Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(article): Add MD support #1451

Merged
merged 26 commits into from
Dec 30, 2024
Merged

feat(article): Add MD support #1451

merged 26 commits into from
Dec 30, 2024

Conversation

WaDadidou
Copy link
Collaborator

@WaDadidou WaDadidou commented Dec 9, 2024

Needs, todos, etc => https://hackmd.io/@9Oh5kimjS1SP8xUWU_-Ovg/HkcuBoN4yx

We use this library to generate HTML from Markdown syntax: https://github.com/markdown-it/markdown-it
We use this library to render the HTML into JSX: https://github.com/meliorence/react-native-render-html

MarkdownIt

Here, we initialize MarkdownIt with some parameters, and use the Article message to render HTML: https://github.com/TERITORI/teritori-dapp/blob/feat-feed-article-markdown/packages/screens/FeedNewArticle/components/ArticleContentEditor/ArticleContentEditor.tsx#L53
We use the same MarkdownIt parameters at Article creation and Article consultation (WYSIWYG).

RenderHtml

We pass custom styles to RenderHtml. Each style item correspond to an html tag. So, there are a lot of customisable styles. We could customise the most used only: https://github.com/TERITORI/teritori-dapp/blob/feat-feed-article-markdown/packages/screens/FeedNewArticle/components/ArticleContentEditor/ArticleContentEditor.tsx#L169
Here are the currently customized styles: https://github.com/TERITORI/teritori-dapp/blob/feat-feed-article-markdown/packages/screens/FeedNewArticle/components/ArticleContentEditor/utils.ts#L14-L112

Temporary stuff. Please take attention to that: At the final, we'll have only one Article category, type, view, etc. These stuff will be merged with the actual "Article" stuff, and the mention "Markdown" will be removed in the future

ArticleMarkdown:


ZodSocialFeedArticleMarkdownMetadata:
export const ZodSocialFeedArticleMarkdownMetadata = z.object({

FeedPostArticleMarkdownView:
// TODO: It's a copy of FeedPostArticleView.tsx, just made waiting for a posts UI (and data) refacto

SocialArticleMarkdownCard :
// TODO: It's a copy of SocialArticleCard.tsx, just made waiting for a posts UI (and data) refacto. => Merge them in the future

Copy link

netlify bot commented Dec 9, 2024

Deploy Preview for gno-dapp ready!

Name Link
🔨 Latest commit ad5c97c
🔍 Latest deploy log https://app.netlify.com/sites/gno-dapp/deploys/6772557baa0cb90008eae052
😎 Deploy Preview https://deploy-preview-1451--gno-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 9, 2024

Deploy Preview for teritori-dapp ready!

Name Link
🔨 Latest commit ad5c97c
🔍 Latest deploy log https://app.netlify.com/sites/teritori-dapp/deploys/6772557bf138830008c557ca
😎 Deploy Preview https://deploy-preview-1451--teritori-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@WaDadidou WaDadidou force-pushed the feat-feed-article-markdown branch from 12ef521 to 271f701 Compare December 12, 2024 00:53
@WaDadidou WaDadidou changed the title wip(article): Add MD support feat(article): Add MD support Dec 12, 2024
@WaDadidou WaDadidou marked this pull request as ready for review December 12, 2024 00:54
@WaDadidou WaDadidou force-pushed the feat-feed-article-markdown branch from 2bb197f to a8cab39 Compare December 12, 2024 01:34
@WaDadidou WaDadidou force-pushed the feat-feed-article-markdown branch from a8cab39 to 6408c7a Compare December 12, 2024 01:50
@clegirar
Copy link
Collaborator

In term of UI what do you think about show borders for the editor and the preview ?

@clegirar
Copy link
Collaborator

In term of behvior found that enough for a first version and we can iterate on add styles just after.
Cool to see this first version 🙂

@MikaelVallenet
Copy link
Member

Would be nice to highlight the selected mode

image

@MikaelVallenet
Copy link
Member

it would also be nice (in another PR since it's not the scope) but to use the start of the article to make a preview subtitle and let it optional to write a custom preview, if you agree i will open a new issue

@WaDadidou
Copy link
Collaborator Author

WaDadidou commented Dec 16, 2024

@clegirar

In term of UI what do you think about show borders for the editor and the preview ?

If you talk about the white borders, it's the same behavior than on other inputs.

image

I try to put this behavior on each input, I love this UI that highlights interactive elements on hover such as inputs or buttons.. In mobile format, I removed the white borders padding, because there is no hover.

If to talk about a separation between preview and edition, why not adding one, yes :) Personnaly I prefer pure without separation, it's enough excplicit

@WaDadidou
Copy link
Collaborator Author

WaDadidou commented Dec 16, 2024

image

Would be nice to highlight the selected mode

@MikaelVallenet @clegirar

These are draft buttons, I'm looking for better buttons, an other style for these buttons, maybe with icons, something cute.
I'll restyle these buttons

packages/utils/feed/markdown.ts Outdated Show resolved Hide resolved
@WaDadidou WaDadidou added enhancement New feature or request UX/UI Social Feed Everything related to the Social Feed labels Dec 23, 2024
@@ -123,6 +123,8 @@ const gradient = (type: GradientType): LinearGradientProps => {
return getMapPostTextGradient(PostCategory.Normal);
case getMapPostTextGradientType(PostCategory.Article):
return getMapPostTextGradient(PostCategory.Article);
case getMapPostTextGradientType(PostCategory.ArticleMarkdown):
return getMapPostTextGradient(PostCategory.Article);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this on purpose ?

Copy link
Collaborator Author

@WaDadidou WaDadidou Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have a new PostCategory ArticleMarkdown (for now), yes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completed the description

Please take attention to that: At the final, we'll have only one Article category, type, view, etc. These stuff will be merged with the actual "Article" stuff, and the mention "Markdown" will be removed in the future

Comment on lines 54 to 55
fontFamily: "Exo_500Medium",
fontWeight: "500",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make a const for those repeated values ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!
a58719b

event.contentOffset.y >= event.contentSize.height - offsetPadding &&
isNextPageAvailable.value
) {
fetchNextPage();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this code will be triggered every time onScroll event is fired, we should add isFetching flag to block that

Copy link
Collaborator Author

@WaDadidou WaDadidou Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FeedPostArticleMarkdownView is a copy of FeedPostArticleView.
FeedPostArticleView will be deleted soon (I hope)
We need to refacto the posts UI code. I don't want this PR being messy, the purpose is just to add a Markdown editor. But it implies to add a new PostCategory, so a new Zod type, so a new FeedPostBlablaView...
And all of these, temporary...

I forgot that could be slow down the review.

I don't know how to avoid adding this kind of copy without adding more complexity that will be removed just after

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completed the description

Please take attention to that: At the final, we'll have only one Article category, type, view, etc. These stuff will be merged with the actual "Article" stuff, and the mention "Markdown" will be removed in the future

MikaelVallenet
MikaelVallenet previously approved these changes Dec 28, 2024
};

// HTML tags styles used by RenderHtml from react-native-render-html
export const renderHtmlTagStyles: MixedStyleRecord = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-12-29 at 13 34 54

is it expected that the h1 has a space on top?

Copy link
Collaborator Author

@WaDadidou WaDadidou Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Headings vertical spaces and line height makes it thick
image

Top space to compensate the input's borders padding
image

Anyway, yes, the preview takes more space, we can't avoid that
image

Copy link
Collaborator

@n0izn0iz n0izn0iz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can merge and iterate

Copy link
Collaborator

@hthieu1110 hthieu1110 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@WaDadidou WaDadidou enabled auto-merge December 30, 2024 17:30
@WaDadidou WaDadidou added this pull request to the merge queue Dec 30, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 30, 2024
@n0izn0iz n0izn0iz added this pull request to the merge queue Dec 30, 2024
Merged via the queue into main with commit 80f9ca4 Dec 30, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Social Feed Everything related to the Social Feed UX/UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants